package com.hockeo.client.ui.views;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.hockeo.client.ui.base.tree.IVHTreeConfig;
import com.hockeo.shared.domain.transitory.LocalTreeItem;

/**
 * Configuration for the main menu navigation tree.
 *
 * @version $Id$
 * @author jjanke
 */
public class NavigationTreeConfig implements IVHTreeConfig
{
  @Override
  public AbstractImagePrototype getIcon( BeanModel model )
  {
    // TODO
    return null;
  }

  @Override
  public String getLabel( BeanModel model )
  {
    Object objBean = model.getBean();

    if ( objBean instanceof LocalTreeItem )
      return ( (LocalTreeItem) objBean ).getLabel();

    return model.getBean().toString();
  }

  @Override
  public boolean hasChildren( BeanModel model )
  {
    // TODO
    return true;
  }

  @Override
  public void loadChildNodes( BeanModel modelParent, AsyncCallback<List<?>> callback )
  {
    // TODO

  }

  @Override
  public void loadRoots( AsyncCallback<List<?>> callback )
  {
    LocalTreeItem lti = new LocalTreeItem( "countries", "Countries" );
    //BeanModelFactory factory = BeanModelLookup.get().getFactory( LocalTreeItem.class );
    //BeanModel model = factory.createModel( lti );

    ArrayList<LocalTreeItem> list = new ArrayList<LocalTreeItem>();
    list.add( lti );

    callback.onSuccess( list );
  }

}
